/**
 * Project Name:kany-project-spring-boot
 * File Name:MyBatisMapperScannerConfig.java
 * Package Name:me.kany.project.spring.boot.config
 * Date:2016年5月10日下午4:34:00
 * Copyright (c) 2016, Jason.Wang All Rights Reserved.
 *
*/

package me.kany.project.spring.boot.config.mybatis;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName:MyBatisMapperScannerConfig <br/>
 * Function: 主要用来扫描**Mapper.java这样的配置文件. <br/>
 * Date:     2016年5月10日 下午4:34:00 <br/>
 * @author   Jason.Wang
 * @version  
 * @since    JDK 1.7
 * @see 	 
 */
@Configuration
//注意，由于MapperScannerConfigurer执行的比较早，所以必须有下面的注解
@AutoConfigureAfter(MyBatisConfig.class)
public class MyBatisMapperScannerConfig {
	
	/**
	 * 
	 * mapperScannerConfigurer:主要用来执行扫描Mapper的类. <br/>
	 *
	 * @author Jason.Wang
	 * @return
	 * @since JDK 1.7
	 */
	@Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        //设置sqlSessionFactory的对象
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        //具体需要扫描的包名
        mapperScannerConfigurer.setBasePackage("me.kany.project.spring.boot.mapper");
        return mapperScannerConfigurer;
    }
}
